<template>
  <view class v-if="visible">
    <view class="followInfo">
      <view class="followInfobox">
        <view class="followInfo_title">🐮🐴吃什么自己来定</view>
        <view class="clearData" @click="clearData">清空</view>
      </view>

      <view class="followInfo_content">
        <view class="radiobox" v-for="(item, index) in list" :key="index">
          <view class="">
            <view class="card_label">
              <view class="label_txt">
                <view>美食{{ index + 1 }}：</view>
              </view>
            </view>
            <view class="card_select">
              <view class="select_time">
                <input
                  v-model="item.title"
                  class="text_val"
                  placeholder="吃什么餐自己填"
                />
              </view>
            </view>
          </view>
        </view>
      </view>
      <view class="fixCenter_btn">
        <view class="cancel_btn" @click="closePop">🐮取消</view>
        <view class="confirm_btn" @click="formOnSubmit">🐴确认</view>
      </view>
    </view>
    <view class="mask" @click.stop="closePop"></view>
  </view>
</template>

<script>

export default {
  components: {
   
  },
  props: {
    visible: {
      type: Boolean,
      default: false,
    },

    dataSource: {
      type: Array,
      default: null,
    },
  },
  data() {
    return {
      showTimerPicker: false,
      list: {},
    };
  },

  mounted() {},
  watch: {
    visible: {
      handler: function (val, oldVal) {
        if (val) {
          this.list = JSON.parse(JSON.stringify(this.dataSource));
        }
      },
      deep: true,
      immediate: false,
    },
  },
  methods: {
    getFieldVal(index, value) {
      this.dataSource[index].title = value;
    },

    // 获取list名称
    getFieldName(list, key, val) {
      if (list && list.length > 0) {
        let obj = list.filter((item) => {
          return item[key] == val;
        });
        if (obj.length > 0) {
          return obj[0].name;
        }
      }
      return null;
    },

    formOnSubmit() {
      for (let i = 0; i < this.list.length; i++) {
        let item = this.list[i];
        if (!item.title) {
          Toast("把自己的🐮🐴餐都填上");
          return;
        }
        this.$emit("editFoods", this.list);
		uni.setStorageSync('foods',JSON.stringify(this.list))
        this.closePop();
      }
    },
    closePop() {
      this.$emit("close");
    },

    // 校验方法
    vaiFormdata() {},

    onClickLeft() {
      this.$router.go(-1);
    },

    clearData() {
      this.list.forEach((item) => {
        item.title = "";
      });
    },
  },
};
</script>

<style lang="less" scoped>
body {
  // background: #f3f3f3;
}
.flex {
  display: flex;
  align-items: center;
}
.registerDetail {
  background: #f3f3f3;
  overflow: hidden;
  .detail_header {
    justify-content: space-between;
    margin: 0.2rem 0.2rem;
    border-radius: 5px;
    background: #fff;
    padding: 0.3rem;
    .detail_header_lt {
      .carNo {
        font-size: 0.32rem;
        font-weight: bold;
        margin-bottom: 0.2rem;
        .carStatus {
          border: 1px solid #35bc04;
          color: #35bc04;
          border-radius: 5px;
          padding: 0.1rem 0.1rem;
          font-size: 0.24rem;
          text-align: center;
          margin-left: 0.1rem;
        }
      }
      .hank {
        font-size: 0.28rem;
        color: #666;
        .name {
          border-right: 2px solid #ccc;
          padding-right: 0.1rem;
          margin-right: 0.1rem;
        }
      }
    }
    .detail_header_rt {
      justify-content: flex-start;
      .txt {
        font-size: 0.28rem;
        color: #161616;
      }
      .icon-tel {
        color: #fff;
        background: #35bc04;
        font-size: 0.32rem;
        padding: 0.1rem;
        border-radius: 50%;
        margin-right: 0.1rem;
      }
    }
  }
  .formData {
    background: #fff;
    overflow: hidden;
  }
}

.submitBtn {
  background: #409eff;
  color: #fff;
  width: 75%;
  margin: auto;
  text-align: center;
  padding: 0.25rem;
  border-radius: 5px;
  margin-top: 0.6rem;
  font-size: 0.3rem;
  margin-bottom: 0.5rem;
}
.voicebox {
  position: relative;
  .icon-voice {
    position: absolute;
    bottom: 10px;
    right: 10px;
    font-size: 20px;
    color: #409eff;
  }
}
.task_detail {
  // margin-top: 50px;
  .task_detail_header {
    padding: 17px 0 10px;
    background: #fff;
    // margin-bottom: 10px;
    border-bottom: 1px solid #f1f1f1;
    position: relative;

    .title {
      text-align: center;
      font-family: Alibaba;
      font-weight: 700;
      font-size: 16px;
      color: #333333;
      max-width: 70%;
      text-overflow: ellipsis;
      white-space: nowrap;
      overflow: hidden;
      margin: auto;
    }
    .name {
      display: flex;
      text-align: center;
      width: 100%;
      justify-content: center;
      margin-top: 10px;

      .txt {
        font-family: Alibaba;
        font-weight: 400;
        font-size: 12px;
        color: #999999;
        text-align: center;
        margin-right: 10px;
      }
    }
    .tel_icon {
      position: absolute;
      top: 16px;
      right: 10px;
      width: 29px;
    }
  }
  .follow_result {
    padding: 10px;
    // border-bottom: 6px solid #f7f7f7;
    border-bottom: 1px solid #f7f7f7;
    max-width: 96%;
    overflow: auto;
    &::-webkit-scrollbar {
      display: none;
    }
    .follow_resultbox {
      display: flex;
    }

    .itembox {
      font-weight: 400;
      font-size: 12px;
      color: #4e5969;
      border-radius: 32px 32px 32px 32px;
      background: #f7f7f7;
      padding: 8px 10px;
      margin-right: 10px;
      &.active {
        color: #165dff;
        background: #d8e3ff;
        border-radius: 32px 32px 32px 32px;
      }
    }
  }

  .tabbox {
    // padding: 0 10px;
    padding-top: 15px;
    border-top: 1px solid #f7f5f5;
    margin-top: 15px;
    position: relative;
    width: 7.5rem;
    overflow: hidden;
    .tab_list {
      width: 10rem;
      overflow-x: auto;
      clear: both;
      .tab_item {
        font-weight: 400;
        font-size: 14px;
        color: #4e5969;
        text-align: center;
        background: #f7f7f7;
        border-radius: 32px;
        padding: 8px 16px;
        margin-right: 6px;
        cursor: pointer;
        float: left;
        &:last-child {
          margin-right: 0;
        }
        &.active {
          color: #165dff;
          text-align: center;
          background: #d8e3ff;
        }
      }
    }
  }
}

.followInfo {
  position: fixed;
  width: 100%;
  height: calc(100vh - 116px);
  overflow: auto;
  bottom: 0;
  left: 0;
  z-index: 102;
  box-shadow: 0px 1px 0px 0px rgba(40, 47, 56, 0.04);
  border-radius: 10px 10px 0px 0px;
  background: #fff;
  &::-webkit-scrollbar {
    display: none;
  }
  .followInfobox {
    border-radius: 10px 10px 0px 0px;
    position: fixed;
    top: 116px;
    left: 0;
    width: 100%;
    background: #fff;
  }
  .followInfo_title {
    text-align: center;
    padding: 10px;
    border-bottom: 1px solid #f2f2f2;
    font-weight: 600;
    font-size: 17px;
    color: #1d2129;
  }

  .followInfo_content {
    padding: 10px;
    border-top: 6px solid #f7f7f7;
    margin-bottom: 60px;
    margin-top: 35px;
    .followInfo_item {
      margin-bottom: 10px;
    }

    .followInfo_name {
      margin-bottom: 10px;
      .name {
        width: 100px;
        padding: 5px 8px;
        font-weight: 700;
        font-size: 10px;
        color: #165dff;
        background: #e8f5ff;
        border-radius: 2px 2px 2px 2px;
      }
    }
  }
}
.mask {
  position: fixed;
  width: 100%;
  height: 100vh;
  bottom: 0;
  left: 0;
  z-index: 101;
  background: rgba(0, 0, 0, 0.5);
}
.radiobox {
  box-shadow: 0px 5px 5px 0px rgba(0, 0, 0, 0.02);
  border-radius: 4px 4px 4px 4px;
  border: 1px solid #f4f4f6;
  padding: 8px 17px 20px 17px;
  .card_label {
    display: flex;
    margin-bottom: 10px;
    .require_icon {
      font-weight: 400;
      font-size: 12px;
      color: #ff4848;
    }
    .label_txt {
      font-weight: 400;
      font-size: 12px;
      display: flex;
      color: #86909c;
    }
  }
  .card_select {
    display: flex;
    flex-wrap: wrap;
    .radio_item {
      width: 33%;
      display: flex;
      align-items: center;
      .item_icon {
        width: 18px;
        display: block;
        margin-right: 10px;
      }
      .item_name {
        font-weight: 600;
        font-size: 12px;
        color: #2f2f2f;
      }
    }
    .select_time {
      width: 100%;
      display: flex;
      justify-content: space-between;
      align-items: center;
      .time_val {
        font-weight: 700;
        font-size: 12px;
        color: #2f2f2f;
      }
      .icon-right {
        font-size: 16px;
        color: #c9cdd4;
      }
    }
  }
}
.fixCenter_btn {
  display: flex;
  width: 100%;
  box-sizing: border-box;
  position: fixed;
  bottom: 0;
  left: 0;
  background: #fff;
  z-index: 999;
  .cancel_btn {
    width: 50%;
    font-weight: 400;
    font-size: 18px;
    color: #1d2129;
    border-right: 1px solid #e5e6eb;
    padding: 12px;
    text-align: center;
  }
  .confirm_btn {
    font-weight: 400;
    width: 50%;
    font-size: 18px;
    color: #165dff;
    padding: 12px;
    text-align: center;
  }
}
.clearData {
  position: absolute;
  top: 10px;
  right: 10px;
  color: #165dff;
  cursor: pointer;
}
.radiobox {
  box-shadow: 0px 5px 5px 0px rgba(0, 0, 0, 0.02);
  border-radius: 4px 4px 4px 4px;
  border: 1px solid #f4f4f6;
  padding: 8px 17px 20px 17px;
  .card_label {
    display: flex;
    margin-bottom: 10px;
    .require_icon {
      font-weight: 400;
      font-size: 12px;
      color: #ff4848;
    }
    .label_txt {
      font-weight: 400;
      font-size: 12px;
      width: 100%;
      color: #86909c;
      display: flex;
      justify-content: space-between;
      align-items: center;
      .voice_icon {
        font-weight: 400;
        font-size: 12px;
        display: flex;
        align-items: center;
        color: #165dff;
        .voice_icon_img {
          width: 12px;
        }
      }
    }
  }
  .card_select {
    display: flex;
    flex-wrap: wrap;
    .radio_item {
      width: 33%;
      display: flex;
      align-items: center;
      .item_icon {
        width: 18px;
        display: block;
        margin-right: 10px;
      }
      .item_name {
        font-weight: 600;
        font-size: 12px;
        color: #2f2f2f;
      }
    }
    .select_time {
      width: 100%;
      display: flex;
      justify-content: space-between;
      align-items: center;
      .time_val {
        font-weight: 700;
        font-size: 12px;
        color: #2f2f2f;
      }
      .icon-right {
        font-size: 16px;
        color: #c9cdd4;
      }
      .text_val {
        width: 100%;
        background: #f2f3f5;
        border: none;
        font-weight: 300;
        font-size: 10px;
        color: #333;
        display: block;
        padding: 8px 10px;
        &::placeholder {
          color: #c9cdd4;
        }
      }
    }
    .fast_select {
      display: flex;
      flex-wrap: wrap;
      padding-top: 20px;
      .fast_select_item {
        color: #666;
        padding: 5px 10px;
        margin-right: 10px;
        font-size: 12px;
        color: #4e5969;
        border-radius: 32px 32px 32px 32px;
        background: #f7f7f7;
        margin-bottom: 10px;
        &.active {
          color: #165dff;
          background: #d8e3ff;
        }
      }
    }
  }
}
</style>
